package arithmetic;

import java.lang.*;
import java.util.*;

/**
 * 螺旋数组
 */
public class Spiral_number {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(("请输入螺旋行数或者列数"));
        //定义二维数组
        int row = in.nextInt();
        int[][] number = new int[row][row];
        //设计label
        int label = 0;
        int i;
        //外层i控制行数
        for (i = 0; i < row - label; i++) {
            int k;
            //输入每次循环的第一行
            for (k = label; k < row - label; k++) {
                number[i][k] = in.nextInt();
            }
            int j;
            //输入每次循环的最后一列
            for (j = i + 1; j < row - label; j++) {
                number[j][k - 1] = in.nextInt();
            }
            int l;
            //输入每次循环的最后一行
            for (l = k - 2; l >= label; l--) {
                number[j - 1][l] = in.nextInt();
            }
            int m;
            //输入每次循环的第一列
            for (m = j - 2; m > label; m--) {
                number[m][l + 1] = in.nextInt();
            }
            //让label递增 进入下一轮循环
            label++;
        }
        for (int k = 0; k < row; k++) {
            for (int j = 0; j < row; j++) {
                System.out.print(number[k][j] + "\t");
            }
            System.out.println();
        }
    }
}
